<!-- BEGIN PAGE HEADER-->   
<div class="row-fluid">
    <div class="span12">
        <!-- BEGIN THEME CUSTOMIZER-->

        <!-- END THEME CUSTOMIZER-->
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <div style="clear:both; height:20px"></div>
        <ul class="breadcrumb">
            <li>
                <a href="<?php echo $this->Html->url(array("controller" => "home", "action" => "index")); ?>">Home</a>
                <span class="divider">/</span>
            </li>
<!--             <li class="active"> -->
<!--                <a href="<?php //echo $this->Html->url(array("controller" => "home", "action" => "master")); ?>">マスター</a>-->
<!--                 <span class="divider">/</span> -->
<!--             </li> -->
            <li class="active">カメラの監視機能                       
            </li>
            
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
        <div class="row-fluid">
            <div class="span12">


                <!-- BEGIN EXAMPLE TABLE widget-->

                <div class="control-group">
                    <?php echo $this->Form->create('Camera', array(
                            'inputDefaults' => array(
                                    'div' => 'control-group',
                                    'label' => array(
                                            'class' => 'control-label'
                                    ),
                                    'wrapInput' => 'controls'
                            ),
                            'class' => 'form-horizontal'
                    )); 
                    ?>
                    <?php 
                        echo $this->Form->input('Camera.CustId', array(
                            'label' => array(
                                    'text' => 'お客様名'
                            ),
                            'empty' => false,
                            'options' => $this->Common->listCustomer(true),
                            'class' => 'span4',
                            'id' => 'search_customer'
                    )); 
                    ?>
                    <?php 
                        echo $this->Form->input('Camera.BuildId', array(
                            'label' => array(
                                    'text' => '物件名'
                            ),
                            'empty' => false,
                            'options' => $this->Common->listBulding(),
                            'class' => 'span4',
                            'id' => 'search_building'
                    )); 
                    ?>
                    <?php 
                    echo $this->Form->input('Camera.CamName', array(
                            'placeholder' => 'カメラ名',
                            'label' => array(
                                    'text' => 'カメラ名'
                            ),
                            'class' => 'span4',
                            'type' => 'text',
                            'required' => false
                    )); 
                    ?>
                    <div class="control-group required">
                        <label for="CameraName" class="control-label">
                            <button class="btn btn-success" type="submit">
                                <i class="icon-ok icon-white"></i> 検索
                            </button>
                        </label>
                        <div class="controls required">
                        </div>
                    </div>
                    <?php echo $this->Form->end(); ?>
                </div>
<!--                <p>
                    <button class="btn btn-warning"><i class="icon-plus icon-white"></i> Create</button>
                    <button class="btn btn-inverse"><i class="icon-refresh icon-white"></i> Update</button>
                    <button class="btn btn-primary"><i class="icon-pencil icon-white"></i> Edit</button>
                    <button class="btn btn-danger"><i class="icon-remove icon-white"></i> Delete</button>
                    <button class="btn btn-info"><i class="icon-ban-circle icon-white"></i> Cancel</button>
                    <button class="btn btn-success"><i class="icon-ok icon-white"></i> Approve</button>
                </p>-->

                <div class="widget gray">
                    <div class="widget-title">
                        <h4><i class="icon-reorder"></i> カメラの監視機能</h4>
                        <span class="tools">
                            <a href="javascript:;" class="icon-chevron-down"></a>

                        </span>
                    </div>
                    <div class="widget-body">
                        <table class="table table-striped table-bordered" id="sample_1">
                            <thead>
                                <tr>
                                    <th class="text-center">カメラID</th>
                                    <th >カメラ名</th>
                                    <th >カメラIP</th>
                                    <th >物件名</th>
                                    <th style="width: 60px" >アラート</th>
                                    <th style="width: 80px" >&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
<?php foreach ($cameras as $camera): ?>
                                    <tr class="odd gradeX">
                                        <td class="text-center"><?php echo $camera['Camera']['CamID']?></td>
                                        <td ><?php echo $camera['Camera']['CamName']?></td>
                                        <td><?php echo $camera['Camera']['UniIp']?>:<?php echo $camera['Camera']['HttpPort']?></td>
                                        <td><?php echo $camera['Building']['BuildName']?></td>
                                        <td class="hidden-phone">  
                                            <?php if($camera['Camera']['Off']): ?>
                                            <button class="btn btn-mini btn-danger" type="button"> <i class="icon-bell-alt"></i>
                                                Off</button>
                                            <?php else:
                                                echo '&nbsp;';
                                            endif; ?>
                                        </td>
                                        <td>
                                            <div  style="margin-top:3px"><i class="icon-map-marker"></i> 
                                                <a data-address="<?php echo $camera['Building']['BuildAddress']?>" class="view_map">View map</a>
                                            </div>
                                        </td>
                                    </tr>
<?php endforeach; ?>

                        </table>
                    </div>
                </div>
                <!-- END EXAMPLE TABLE widget-->


            </div>
        </div>
    </div>
</div>
<!-- END PAGE HEADER-->
<script>
$(document).ready(function(){
    //
    
    if($("#search_customer").size() > 0){
        getBuilding('<?php echo isset($_REQUEST['data']['Camera']['BuildId'])?$_REQUEST['data']['Camera']['BuildId']:"-1"?>',0);
    }
    $("#search_customer").on('change',function(){
        getBuilding(-1,0);
    });
    
});
</script>